package main

import (
	"goWeb/bookStore/controller"
	"net/http"
)

func main() {
	//处理静态资源
	http.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.Dir("views/static"))))
	http.Handle("/pages/", http.StripPrefix("/pages", http.FileServer(http.Dir("views/pages"))))
	//处理登录
	http.HandleFunc("/login", controller.Login)
	http.HandleFunc("/CheckLogin", controller.CheckLogin)
	//处理注销
	http.HandleFunc("/logout", controller.LogOut)
	//处理注册
	http.HandleFunc("/register", controller.Register)
	http.HandleFunc("/CheckRegister", controller.CheckRegister)
	http.HandleFunc("/CheckUserName", controller.CheckUserName)

	//获取所有图书
	http.HandleFunc("/getBooks", controller.GetBooks)
	//添加图书
	http.HandleFunc("/addOrUpdateBooks", controller.AddOrUpdateBooks)
	//删除图书
	http.HandleFunc("/delBook", controller.DelBook)
	//去修改图书的页面
	http.HandleFunc("/toUpdateBook", controller.ToUpdateBook)

	//去首页
	//http.HandleFunc("/main", controller.GetAllBook)
	http.HandleFunc("/main", controller.GetBookByPrice)
	//根据价格查询
	http.HandleFunc("/getBookByPrice", controller.GetBookByPrice)

	//添加图书到购物车
	http.HandleFunc("/addBookToCart", controller.AddBookToCart)
	//去购物车
	http.HandleFunc("/toCart", controller.ToCart)
	//清空购物车
	http.HandleFunc("/emptyCart", controller.EmptyCart)
	//删除购物项
	http.HandleFunc("/deleteCartItem", controller.DeleteCartItem)
	//更新购物项的数量
	http.HandleFunc("/toUpdateCartCount", controller.ToUpdateCartCount)

	//去结账
	http.HandleFunc("/toCheckOut", controller.ToCheckOut)
	//后台订单管理
	http.HandleFunc("/ordersManager", controller.OrdersManager)
	//查看订单详情
	http.HandleFunc("/toOrderItem", controller.ToOrderItem)
	//我的订单
	http.HandleFunc("/toMyOrders", controller.ToMyOrders)
	//去发货
	http.HandleFunc("/toSendOrders", controller.ToSendOrders)
	//去收货
	http.HandleFunc("/toTakeOrders", controller.ToTakeOrders)

	http.ListenAndServe(":8080", nil)

}
